/*
 * Copyright 2018-present KunMinX
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nsgf.library.ui.adapter;

import android.content.Context;

import androidx.recyclerview.widget.RecyclerView;

import com.kunminx.binding_recyclerview.adapter.SimpleDataBindingAdapter;
import com.nsgf.library.R;
import com.nsgf.library.data.bean.LibraryInfo;
import com.nsgf.library.databinding.ItemNsgfRainfallBinding;
import com.nsgf.library.utils.UnitTo;

/**
 * Create by GC at 24/10/19
 */
public class HomeSearchListAdapter extends SimpleDataBindingAdapter<LibraryInfo, ItemNsgfRainfallBinding> {

    int type;

    public HomeSearchListAdapter(Context context, int type) {
        super(context, R.layout.item_nsgf_rainfall, DiffUtils.getInstance().getLibraryInfoItemCallback());
        this.type = type;
    }

    @Override
    protected void onBindItem(ItemNsgfRainfallBinding binding, LibraryInfo item, RecyclerView.ViewHolder holder) {
        item.setType(String.valueOf(type));
        binding.setVm(item);

        if ("大雨".equals(item.getTodayRainType())) {
            UnitTo.setBorder(mContext, R.color.color_A0D1F6, R.color.color_E5F5FF, R.color.color_A0D1F6, binding.tvNsfRainfallType, 10);
        } else if ("暴雨".equals(item.getTodayRainType())) {
            UnitTo.setBorder(mContext, R.color.color_EDC592, R.color.color_FDF1E4, R.color.color_EDC592, binding.tvNsfRainfallType, 10);
        }else if ("大暴雨".equals(item.getTodayRainType())) {
            UnitTo.setBorder(mContext, R.color.color_FAB786, R.color.color_FFEDE0, R.color.color_FAB786, binding.tvNsfRainfallType, 10);
        }else if ("特大暴雨".equals(item.getTodayRainType())) {
            UnitTo.setBorder(mContext, R.color.color_EB4E4F, R.color.color_FEF0F0, R.color.color_EB4E4F, binding.tvNsfRainfallType, 10);
        }
    }
}
